<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateFeedbacksTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('think_feedbacks', [
            'id' => 'id',
            'signed' => true,
            'auto_increment' => true
        ]);
        
        $table
            ->addColumn('user_id', 'integer', ['null' => false, 'comment' => '用户ID'])
            ->addColumn('suggestion', 'string', ['limit' => 100, 'null' => false, 'comment' => '反馈内容'])
            ->addColumn('photos', 'text', ['null' => true, 'comment' => '图片链接，JSON格式'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '状态：0未处理，1已处理'])
            ->addColumn('create_time', 'datetime', ['null' => false])
            ->addColumn('update_time', 'datetime', ['null' => false])
            ->create();
    }
}
